/**
线程之间对chan的读取和写入
 */
package main

import (
	"fmt"
	"time"
)

func write(ch chan int) {
	//inChan的长度是10 当超过10时这个线程会被堵塞
	for i:= 0;i <100 ;i++{
		ch <- i
	}
}

func read(ch chan int) {
	for {
		i := <- ch
		fmt.Println(i)
	}
}

func main() {
	intChan := make(chan int ,10)
	go write(intChan)
	go read(intChan)
	time.Sleep(time.Second * 5)
}
